package com.member.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.member.dao.MemberDao;
import com.member.domain.MemberCommand;

@Controller
public class MyPasswdCheckController {

	@Autowired
	private MemberDao memberDao;
	
	@RequestMapping(value="/shop/passwdCheck.do", method=RequestMethod.GET)
	public String form(){
		
		return "passwdCheck";
	}
	
	
	@RequestMapping(value="/shop/passwdCheck.do", method=RequestMethod.POST)
	public ModelAndView porcess(@RequestParam(value="m_passwd") String m_passwd, HttpSession session){
		String userId = (String)session.getAttribute("userId");
		
		String result = null;
		
		if(m_passwd.equals(memberDao.checkId(userId))){
			
			result = "{\"result\":true}";
		}else{
			result = "{\"result\":false}";
		}
		return new ModelAndView("JSONFILE","result",result);
	}
	
}
